<div class="row spacing-bottom 2col">   
    <div class="col-md-3 col-sm-6 spacing-bottom-sm">   
        <div class="tiles green added-margin">
          <div class="tiles-body">
                <div class="tiles-title">
                    评论总数
                </div>  
                <div class="heading">
                    <span><?= $total ?></span>个
                </div>             
            </div>  
        </div>
    </div>              
</div>

<div class="row">
    <div class="col-md-12">
      <div class="grid simple">
        <div class="grid-title no-border">
            <h4>评论 <span class="semi-bold">查询</span></h4>
            <div class="tools"> 
                <a class="collapse" href="javascript:;"></a>
            </div>
        </div>
        <div class="grid-body no-border">
            <form class="form-no-horizontal-spacing" method="GET" action="<?= DOMAIN.'comment/browse' ?>">
                <div class="row column-seperation">
                    <div class="col-md-4">
                        <div class="form-group col-md-10">
                            <label class="form-label">昵称</label>
                            <input type="text" class="form-control" name="nickname" value="<?= $default['nickname'] ?>" placeholder="eg.G0001">
                        </div>

                        <div class="form-group col-md-10">
                            <label class="form-label">内容</label>
                            <input type="text" class="form-control" name="comment" value="<?= $default['comment'] ?>">
                        </div>
                        <br>
                    </div>

                    <div class="col-md-4">
                        <div class="form-group col-md-10">
                            <label class="form-label">状态</label>
                            <div class="radio radio-control">
                                <input type="radio" checked="checked" id="status-ALL" name="status" value="">
                                <label for="status-ALL">不限</label>
                                <? foreach($comment_status as $k => $v): ?>
                                    <? if($default['status'] == $k): ?>
                                        <input type="radio" checked="checked" value="<?= $k ?>" name="status" id="<?= "status-{$k}" ?>">
                                    <? else: ?>
                                        <input type="radio" value="<?= $k ?>" name="status" id="<?= "status-{$k}" ?>">
                                    <? endif ?>
                                    <label for="<?= "status-{$k}" ?>"><?= $v ?></label>
                                <? endforeach ?>
                            </div>
                        </div>
                        <br>
                    </div>

                    <div class="col-md-4">
                        <div class="form-group col-md-12">
                            <label class="form-label">创建时间</label><br>
                            <input type="text" name="create_time_start" value="<?= $default['create_time_start'] ?>" class="datepicker form-inline col-md-5">
                            <div class="form-inline col-md-2"> ~ </div>
                            <input type="text" name="create_time_end" value="<?= $default['create_time_end'] ?>"class="datepicker form-inline col-md-5">
                        </div><br><br>
                        <div class="form-group col-md-12">
                            <label class="form-label">更新时间</label><br>
                            <input type="text" name="update_time_start" value="<?= $default['update_time_start'] ?>"class="datepicker form-inline col-md-5">
                            <div class="form-inline col-md-2"> ~ </div>
                            <input type="text" name="update_time_end" value="<?= $default['update_time_end'] ?>"class="datepicker form-inline col-md-5">
                        </div>
                    </div>
                </div>

                <div class="form-actions">
                    <div class="pull-left">
                      <button type="submit" class="btn btn-warning btn-cons"><i class="icon-search"></i>&nbsp;查询</button>
                      <button type="button" class="btn btn-white btn-cons" onclick="$.T.reset_form(this)">重置</button>
                    </div>
                </div>
            </form>
        </div>
      </div>
    </div>
</div>

<? if($list): ?>
    <div class="row-fluid">
        <div class="grid simple">
            <div class="grid-title no-border">
            </div>
            <div class="grid-body no-border">
                <? if($list['data']): ?>
                <table id="data-table" class="table table-striped">
                    <colgroup>
                        <col width="">
                        <col width="">
                        <col width="">
                        <col width="">
                        <col width="">
                        <col width="150px">
                    </colgroup>
                    <thead>
                        <tr>
                            <th>状态</th>
                            <th>昵称</th>
                            <th>内容</th>
                            <th>创建时间</th>
                            <th>更新时间</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody>
                        <? foreach($list['data'] as $item): ?>
                        <tr>
                            <td>
                                <? if($item['status'] == COMMENT_STATUS_WAIT): ?>
                                    <span class="label label-warning">
                                <? elseif($item['status'] == COMMENT_STATUS_ON): ?>
                                    <span class="label">
                                <? else: ?>
                                    <span class="label label-important">
                                <? endif ?>
                                    <?= $comment_status[$item['status']] ?>
                                </span>
                            </td>
                            <td><?= $item['nickname'] ?></td>
                            <td title="<?= $item['comment'] ?>"><?= mb_substr($item['comment'], 0, 25) ?>...</td>
                            <td>
                                <span class="muted"><?= time_format($item['create_time']) ?></span>
                            </td>
                            <td>
                                <span class="muted"><?= time_format($item['update_time']) ?></span>
                            </td>
                            <td>
                                <? if($item['status'] == COMMENT_STATUS_WAIT): ?>
                                    <a href="javascript:void(0)" onclick="$.Comment.change_status('<?= $item['comment_id']?>', 'audit');" >
                                        <i class="icon-ok-circle"></i>
                                        审核
                                    </a>
                                    &nbsp;&nbsp;
                                    <a href="javascript:void(0)" onclick="$.Comment.change_status('<?= $item['comment_id']?>', 'off');" >
                                        <i class="icon-ban-circle"></i>
                                        停用
                                    </a>
                                <? elseif($item['status'] == COMMENT_STATUS_ON): ?>
                                    <a href="javascript:void(0)" onclick="$.Comment.change_status('<?= $item['comment_id']?>', 'off');" >
                                        <i class="icon-ban-circle"></i>
                                        停用
                                    </a>
                                <? else: ?>
                                    <a href="javascript:void(0)" onclick="$.Comment.change_status('<?= $item['comment_id']?>', 'on');" >
                                        <i class="icon-rocket"></i>
                                        启用
                                    </a>
                                <? endif ?>
                            </td>
                        </tr>
                        <? endforeach ?>
                    </tbody>
                    <tfoot>
                        <tr>
                            <td colspan="11">
                                每页
                                <select class="select2 pagesize">
                                    <? foreach($pagesize as $k => $v): ?>
                                        <option value="<?= $k ?>" <?= $k == $list['size'] ? 'selected="selected"' : '' ?>><?= $v ?></option>
                                    <? endforeach ?>
                                </select>
                                <?= $pagination ?>
                                <div class="pagination_info">
                                    总计：<?= $list['total'] ?>
                                </div>
                            </td>
                        </tr>
                    </tfoot>
                </table>
                <? else: ?>
                    <h4 class="text-success"><i class="icon-meh"></i> &nbsp;很抱歉，没有找到符合条件的记录。</hr>
                <? endif ?>
            </div>
        </div>
    </div>
<? endif ?>
<script type="text/javascript">
    $(document).ready(function(){
        $('.datepicker').datepicker();
    });

    $.Comment = {

        /**
         * [改变状态]
         */
        change_status: function(sn, act)
        {
            if( $.T.empty(sn) )
            {
                $.T.alert("修改评论状态失败：没有提供评论编码。");
                return false;
            }
            if( $.T.empty(act) )
            {
                $.T.alert("修改评论状态失败：没有提供操作类型。");
                return false;
            }
            $.T.confirm('确认要执行这个操作么？', function(){
                $.getJSON($.G.domain+"comment/change_status/"+sn+"/?act="+act+"&is_ajax=1", function(response)
                {
                    if( false == response.status)
                    {
                        $.T.alert(response.msg);
                    }
                    else
                    {
                        $.T.refresh();
                    }
                });
            });
        }
    }
</script>